package controllers;

import helpers.UrlHelper;

import java.io.IOException;
import java.net.URLDecoder;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CheckUpdateServlet extends HttpServlet{
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException {
		String path = ((HttpServletRequest) request).getRequestURI();
		String domainName = URLDecoder.decode(path.toLowerCase().replaceAll("/uc/", ""),"UTF-8");
		response.setContentType("text/html");
		response.getWriter().println("<script type=\"text/javascript\">");
		response.getWriter().println("window.location = \"" + UrlHelper.getServerUrl(request) + "/u/"+ domainName + "?allow=true\";");
		response.getWriter().println("</script>");
		response.getWriter().close();
		
	}
}
